/*    */ package xin.petstore.framework.web.page;
/*    */ 
/*    */ import java.io.File;
/*    */ import java.io.IOException;
/*    */
/*    */ import java.util.Iterator;
/*    */ import java.util.regex.Matcher;
/*    */ import java.util.regex.Pattern;
/*    */ import org.apache.commons.io.FileUtils;
/*    */ 
/*    */ public class HtmlUtils
/*    */ {
/*    */   public static String replaceImgSrc(String content, String replaceHttp)
/*    */   {
/* 15 */     String patternStr = "<img\\s+[^>]*?src=\"((\\w+?:?//|\\/|\\w*)[^\"]*?)\"[^>]*?>";
/* 16 */     Pattern pattern = Pattern.compile(patternStr, 2);
/* 17 */     Matcher matcher = pattern.matcher(content);
/* 18 */     while (matcher.find()) {
/* 19 */       String url = matcher.group(1);
/* 20 */       if (!url.startsWith("http://")) {
/* 21 */         if (!url.startsWith("/"))
/* 22 */           url = "/" + url;
/* 23 */         content = content.replaceAll(url, replaceHttp + url);
/*    */       }
/*    */     }
/*    */ 
/* 27 */     return content;
/*    */   }
/*    */ 
/*    */   public static String replaceLinkHref(String content, String replaceHttp)
/*    */   {
/* 32 */     String patternStr = "<link\\s+[^>]*?href=[\"|']((\\w+?:?//|\\/|\\w*)[^\"]*?)[\"|'][^>]*?>";
/* 33 */     Pattern pattern = Pattern.compile(patternStr);
/* 34 */     Matcher matcher = pattern.matcher(content);
/* 35 */     while (matcher.find()) {
/* 36 */       String url = matcher.group(1);
/* 37 */       if (!url.startsWith("http://")) {
/* 38 */         if (!url.startsWith("/"))
/* 39 */           url = "/" + url;
/* 40 */         content = content.replaceAll(url, replaceHttp + url);
/*    */       }
/*    */     }
/* 43 */     return content;
/*    */   }
/*    */ 
/*    */   public static String replaceScriptSrc(String content, String replaceHttp)
/*    */   {
/* 48 */     String patternStr = "<script\\s+[^>]*?src=[\"|']((\\w+?:?//|\\/|\\w*)[^\"]*?)[\"|'][^>]*?>";
/* 49 */     Pattern pattern = Pattern.compile(patternStr);
/* 50 */     Matcher matcher = pattern.matcher(content);
/* 51 */     while (matcher.find()) {
/* 52 */       String url = matcher.group(1);
/* 53 */       if (!url.startsWith("http://")) {
/* 54 */         if (!url.startsWith("/"))
/* 55 */           url = "/" + url;
/* 56 */         content = content.replaceAll(url, replaceHttp + url);
/*    */       }
/*    */     }
/* 59 */     return content;
/*    */   }
/*    */ 
/*    */   public static void main(String[] s) {
/*    */     try {
/* 64 */       String con = FileUtils.readFileToString(new File(
/* 65 */         "C:\\Workspaces\\crazy\\target\\crazy\\index.html"));
/* 66 */       Iterator c1 = FileUtils.iterateFiles(new File("C:\\Workspaces\\crazy\\target\\crazy\\page"), new String[] { "ftl" }, true);
/* 67 */       while (c1.hasNext()) {
/* 68 */         File f = (File)c1.next();
/* 69 */         System.out.println(f.getPath());
/*    */       }
/*    */ 
/* 75 */       System.out
/* 76 */         .println("********************************************************");
/*    */     }
/*    */     catch (IOException e)
/*    */     {
/* 80 */       e.printStackTrace();
/*    */     }
/*    */   }
/*    */ }

/* Location:           C:\java代码反编译器\core-1.1.4.jar
 * Qualified Name:     com.eloancn.framework.page.HtmlUtils
 * JD-Core Version:    0.6.0
 */